<?php
/**
+-------------------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发，右手开源，未来可期！]
+-------------------------------------------------------------------------------------------------------
* @Copyright (c) http://blog.gougucms.com All rights reserved.
+-------------------------------------------------------------------------------------------------------
* @Licensed 勾股系列相关开源系统，可免费使用，但并不是自由软件，未经授权许可，不能去除系统的相关版权信息
+-------------------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-------------------------------------------------------------------------------------------------------
*/

declare (strict_types = 1);
namespace app\course\controller;
use app\course\model\Lecturer;
use app\course\model\Material;
use app\course\model\Course;
use app\api\BaseController;
use think\facade\Db;

class Api extends BaseController
{
	//获取专家
    public function get_lecturer()
    {
		$param = get_params();
		$where = [];
		if (!empty($param['keywords'])) {
			$where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
		}
		$where[] = ['delete_time', '=', 0];
		$where[] = ['status', '=', 1];
		$model = new Lecturer();
		$list = $model->datalist($where, $param);
		return table_assign(0, '', $list);
    }
	
	//获取课程内容
    public function get_material()
    {
		$param = get_params();
		$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
		
		$where = [];
		if (!empty($param['keywords'])) {
			$where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
		}
		if (!empty($param['type'])) {
			$where[] = ['type', '=', $param['type']];
		}
		if (!empty($param['mids'])) {
			$where[] = ['id', 'notin', $param['mids']];
		}
		if (!empty($param['ids'])) {
			$where[] = ['id', 'in', $param['ids']];
			$param['rows']=99999;
		}
		$where[] = ['delete_time', '=', 0];
		$model = new Material();
		$list = $model->datalist($where, $param);
		return table_assign(0, '', $list);
    }
	
	//获取课程
    public function get_course()
    {
		$param = get_params();
		$where = [];
		if (!empty($param['keywords'])) {
			$where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
		}
		if (!empty($param['cate_id'])) {
			$where[] = ['cate_id', '=', $param['cate_id']];
		}
		if (!empty($param['cids'])) {
			$where[] = ['id', 'notin', $param['cids']];
		}
		if (!empty($param['ids'])) {
			$where[] = ['id', 'in', $param['ids']];
			$param['rows']=99999;
		}
		$where[] = ['delete_time', '=', 0];
		$where[] = ['status', '=', 1];
		$model = new Course();
		$list = $model->datalist($where, $param);
		return table_assign(0, '', $list);
    }
}
